#!/bin/bash
#文件名： generateXML.sh
#用途：用于新建一个桌面壁纸动画合集
if [ $# -lt 1 ];
then
	echo $0 合集代号
	exit 1
fi

echo '<background>'
echo '  <starttime>'
echo '    <year>2009</year>'
echo '    <month>08</month>'
echo '    <day>04</day>'
echo '    <hour>00</hour>'
echo '    <minute>00</minute>'
echo '    <second>00</second>'
echo '  </starttime>'

last_file='empty'
files=`ls ./$1`
for current_file in $files
do
	if [[ $last_file == 'empty' ]]
	then
		last_file=$current_file
		echo '  <static>'
		echo '    <duration>300.0</duration>'
		echo "    <file>/usr/share/backgrounds/$last_file</file>"
		echo '  </static>'
	else
		echo '  <transition>'
		echo '    <duration>5.0</duration>'
		echo "    <from>/usr/share/backgrounds/$last_file</from>"
		echo "    <to>/usr/share/backgrounds/$current_file</to>"
		echo '  </transition>'
		echo '  <static>'
		echo '    <duration>300.0</duration>'
		echo "    <file>/usr/share/backgrounds/$current_file</file>"
		echo '  </static>'
		last_file=$current_file
	fi
done
echo '</background>'
